(define (accumulate combiner null-value term a next b)
  (if (> a b) null-value
      (combiner a (accumulate combiner null-value term (next a) next b))))

(define (accumulate-iter combiner null-value term a next b)
  (define (acc-intern accumulator a b)
    (if (> a b) accumulator
        (acc-intern (combiner accumulator a) (next a) b)))
  (acc-intern null-value a b))